AddEmployeeController = function() {
	this.addEmployee = function() {
		var user=sessionStorageClient.getJSON("user");
		var tempParamData = CommonUtil.takeOutParamObject();
		if (tempParamData && tempParamData != null) {
			var employeeName = $("#addEmployeePage #employeeName").val();
			var employeeMobile = $("#addEmployeePage #employeeMobile").val();
			var employeeCode = $("#addEmployeePage #employeeCode").val();
			var employeeLevel = $("#employeeLevel").val();
			var affiliation = user.role==4?"2":$("#affiliation").val();
			var onjobStatus ="1";//创建员工默认为在职状态
			var shopId = user.role==4?user.selfShopId:employeeStoreListFilterParam.shopId;
			if(employeeName == ""){
				DialogUtil.dialogWarn("请填写员工姓名");
				return;
			}
			if(employeeName.length > 10){
				DialogUtil.dialogWarn("员工姓名不能超过10个字");
				return;
			}

			if(employeeCode.length > 20){
				DialogUtil.dialogWarn("员工编号不能超过20个字");
				return;
			}
			var  checkNameReg = /^[\u4e00-\u9fffa-zA-Z0-9]+$/;
			if(checkNameReg && !checkNameReg.test(employeeName)){
				DialogUtil.dialogWarn("员工姓名不允许输入特殊字符");
				return;
			}

			if(employeeMobile==""){
				DialogUtil.dialogWarn("请输入手机号码");
				return;
			}
			if(onjobStatus==""){
				DialogUtil.dialogWarn("请填写在职状态");
				return;
			}
			if(employeeLevel==""){
				DialogUtil.dialogWarn("请选择员工角色");
				return;
			}

			if(!CommonUtil.checkMobile(employeeMobile)){
				DialogUtil.dialogWarn("请输入有效的手机号");
				return;
			}

			if(affiliation == "2" && shopId == "") {
				DialogUtil.dialogWarn("请选择所属门店");
				return;
			}
		
			common.loading("请稍候...");
			var postData = {
				shopId : shopId,
				employeeLevel: employeeLevel,
				employeeName : employeeName,
				employeeCode : employeeCode,
				affiliation : affiliation,
				employeeMobile : employeeMobile,
				onjobStatus : onjobStatus
			};
			var serverUrl = App.serverUrl + "app/employee/add.do";

			var sucFunc = function(result) {
		    	if (result.success) {
					employeeManageParams.isSucFlag=true;
					employeeManageParams.handleBack4StoreManage = "load";
					var serverResult = result.resultObject;
					if (serverResult.success) {
						DialogUtil.dialogWarn("员工创建成功!初始密码:手机后6位,为保障账号安全,请提醒员工及时修改。", function() {
							if (serverResult && serverResult!=null) {
								$.router.load("employee_manage.html");
							} else {
								DialogUtil.dialogWarn("添加员工异常!");
							}
						});
					} else {
						DialogUtil.dialogWarn(serverResult.msg);
					}
		      	} else {
					DialogUtil.dialogWarn();
			  	}
		     	common.closeLoading();
			};

			console.info(JSON.stringify(postData));
			AppUtil.call(AppUtil.APIS.SEND_HTTP_REQUEST,
				{
					type: "POST",
					url: serverUrl,
					data: JSON.stringify(postData)
				}, sucFunc);
		} else {
			DialogUtil.dialogWarn("数据异常,添加员工!");
			return false;
		}

	};

};